package com.zzc.sale.controller.apis;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hos.entity.stock.Medicines;
import com.hos.entity.stock.Producer;
import com.hos.vo.Result;
import com.zzc.sale.mapper.ProducerMapper;
import com.zzc.sale.service.ProducerService;
import com.zzc.sale.vo.MedicinesVo;
import com.zzc.sale.vo.ProducerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author：xIAO_ZHOU_TX
 * @date：Created in 2023/12/12 15:00
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/sale/api/erp/producter")
@Api(value = "药品生产厂家信息相关接口",tags = "药品生产厂家信息相关接口")
public class APIProducterController {
    @Resource
    private ProducerService producerService;


    @GetMapping("/selectAllProducter")
    @ApiOperation(value = "查询所有有效的生产厂家信息")
    public Result<List<Producer>> selectAllProducter() {
        List<Producer> producers = producerService.selectAllProducter();
        return new Result<>(200, "查询成功", producers);
    }
    @PostMapping("/listProducterForPage")
    @ApiOperation(value = "查询表格生产商所有信息")
    public Result<Page<Producer>> selectAllProducer(@RequestBody ProducerVo producerVo) {
        Page<Producer> producerPage = producerService.listProducterForPage(producerVo);
        return new Result<>(200, "查询成功", producerPage);

    }
    @PostMapping("/addProducter")
    @ApiOperation(value = "添加生产商信息")
    public Result<Integer> addProducter(Producer producers){
        return new Result<>(200,"添加成功",producerService.addProducter(producers));
    }
    @DeleteMapping("/deleteProducterByIds/{ids}")
    @ApiOperation(value = "删除生产商信息")
    public Result<Integer> deleteProducterByIds(@PathVariable List<Long> ids){
        return new Result<>(200,"删除成功" ,producerService.deleteProducterByIds(ids));
    }
    @PutMapping("/updateProducter")
    @ApiOperation(value = "修改生产商信息")
    public Result updateProducter(@RequestBody Producer producer){
        return new Result<>(200,"修改成功",producerService.updateProducter(producer));
    }
    @PostMapping("/getProducterById/{producterId}")
    @ApiOperation(value = "根据id查询厂商信息")
    public Result<Producer> getProducterById(@PathVariable Long producterId){
        return new Result<>(200,"查询成功",producerService.getProducterById(producterId));

    }




}